﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using JumbotCms.Common;
namespace JumbotCms.WebFile.Ajax
{
    public partial class _tag : JumbotCms.API.FrontAjax
    {
        private string _operType = string.Empty;
        private string _response = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!CheckFormUrl())
            {
                Response.Write("提交有误");
                Response.End();
            }
            Server.ScriptTimeout = 8;//脚本过期时间
            this._operType = q("oper");
            switch (this._operType)
            {
                case "ajaxTopTags":
                    GetTopTags();
                    break;
                default:
                    DefaultResponse();
                    break;
            }

            Response.Write(this._response);
        }

        private void DefaultResponse()
        {
            this._response = "{result :\"未知操作\"}";
        }
        private void GetTopTags()
        {
            //选择的字段要注意大小写
            doh.Reset();
            doh.SqlCmd = "SELECT Top " + q("Num") + " Id,ChannelId,Title FROM [jcms_normal_tag] WHERE ChannelId =" + q("ccid") + " ORDER BY ClickTimes desc,Id desc";
            DataTable dtTag = doh.GetDataTable();
            this._response = "{" + Jumbot.Common.JsonHelp.DtToSON(dtTag) + "}";
            dtTag.Clear();
            dtTag.Dispose();
        }
    }
}